#pragma once
#include <iostream>
#include <string>
#include <functional>


//声明
class Reactor;
class Connection;
using handler_t = std::function<std::string(std::string&)>;

class Connection{
public:
    Connection()
    {

    }

    virtual void Recver()=0;
    virtual void Sender()=0;
    virtual void Excepter()=0;//异常函数是不是在父类中实现好一些???
    virtual int GetFd()=0;

    void SetEvent(int event)
    {
        _event = event;
    }
    int GetEvent()
    {
        return _event;
    }
    void SetOwner(Reactor* owner)
    {
        _owner = owner;
    }
    Reactor* GetOwner()
    {
        return _owner;
    }
    void RegiserHandler(handler_t handler)
    {
        _handler = handler;
    }
    ~Connection()
    {

    }
private:
    
    //文件描述符关心的事件
    int _event;
    //回指指针
    Reactor *_owner;
public:
    //上层处理协议和业务的函数
    handler_t _handler;
};